package zlx.springcloudAlibaba.Controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import zlx.commons.entities.CommonResult;
import zlx.commons.entities.Payment;

import java.util.HashMap;

@RestController
public class PaymentController {
    @Value("${server.port}")
    private String serverPort;

    public static HashMap<Long, Payment> hashMap=new HashMap<>();
    //模拟数据库
    static {
        hashMap.put(1l,new Payment(1l,"886444asd54fs54g4d64g"));
        hashMap.put(2l,new Payment(2l,"465466asd54fs54g4d64g"));
        hashMap.put(3l,new Payment(3l,"565413asd54fs54g4d64g"));

    }
    @GetMapping("/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id") Long id){
        Payment payment=hashMap.get(id);
        CommonResult<Payment> result=new CommonResult(200,"from sql,serverPort:"+serverPort,payment);
        return result;
    }
}
